package com.abc.robot01.activity.compose

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.filled.Bookmarks
import androidx.compose.material.icons.filled.CalendarMonth
import androidx.compose.material.icons.filled.Dashboard
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Group
import androidx.compose.material.icons.filled.Headphones
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.JoinFull
import androidx.compose.material.icons.filled.Keyboard
import androidx.compose.material.icons.filled.Laptop
import androidx.compose.material.icons.filled.Map
import androidx.compose.material.icons.filled.Navigation
import androidx.compose.material.icons.filled.Outbox
import androidx.compose.material.icons.filled.PushPin
import androidx.compose.material.icons.filled.QrCode
import androidx.compose.material.icons.filled.Radio
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.DismissibleDrawerSheet
import androidx.compose.material3.DismissibleNavigationDrawer
import androidx.compose.material3.DrawerValue
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalDrawerSheet
import androidx.compose.material3.ModalNavigationDrawer
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.NavigationDrawerItemDefaults
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.PermanentDrawerSheet
import androidx.compose.material3.PermanentNavigationDrawer
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberDrawerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch

//https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/material3/material3/samples/src/main/java/androidx/compose/material3/samples/PullToRefreshSamples.kt

class DrawerSamples : ComponentActivity() {


    @Composable
    fun CardSample() {
        Card(Modifier.size(width = 180.dp, height = 100.dp)) {
            Box(Modifier.fillMaxSize()) { Text("Card content", Modifier.align(Alignment.Center)) }
        }
    }

    @Composable
    fun ElevatedCardSample() {
        ElevatedCard(Modifier.size(width = 180.dp, height = 100.dp)) {
            Box(Modifier.fillMaxSize()) { Text("ElevatedCard content", Modifier.align(Alignment.Center)) }
        }
    }

    @Composable
    fun OutlinedCardSample() {
        OutlinedCard(Modifier.size(width = 180.dp, height = 100.dp)) {
            Box(Modifier.fillMaxSize()) { Text("Outlined Card content", Modifier.align(Alignment.Center)) }
        }
    }

    @Composable
    fun SurfaceSample() {
        Surface { Text("Text on Surface") }
    }

    @Composable
    fun ClickableSurfaceSample() {
        var count by remember { mutableStateOf(0) }
        Surface(
            onClick = { count++ },
        ) {
            Text("Clickable Surface. Count: $count")
        }
    }

    @Composable
    fun SelectableSurfaceSample() {
        var selected by remember { mutableStateOf(false) }
        Surface(
            selected = selected,
            onClick = { selected = !selected },
        ) {
            Text(text = if (selected) "Selected" else "Not Selected", textAlign = TextAlign.Center)
        }
    }

    @Composable
    fun ToggleableSurfaceSample() {
        var checked by remember { mutableStateOf(false) }
        Surface(
            checked = checked,
            onCheckedChange = { checked = !checked },
            color =
            if (checked) {
                MaterialTheme.colorScheme.surfaceVariant
            } else {
                MaterialTheme.colorScheme.surface
            }
        ) {
            Text(text = if (checked) "ON" else "OFF", textAlign = TextAlign.Center)
        }
    }

    @Composable
    fun SquareButtonSample() {
        Button(onClick = { /* Do something! */ }, shape = ButtonDefaults.filledTonalShape) { Text("Button") }
    }

    @Composable
    fun TextButtonSample() {
        TextButton(onClick = { /* Do something! */ }) { Text("Text Button") }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e("FirstFragment","MainActivity  onCreate");
        setContent {
            MaterialTheme {
                Surface {
                    Column( modifier = Modifier
                        .fillMaxSize()
                        .verticalScroll(rememberScrollState())
                        .padding(8.dp),
                        verticalArrangement = Arrangement.spacedBy(8.dp)) {
//                        DismissibleNavigationDrawerSample()
//                        ModalNavigationDrawerSample()
//                        PermanentNavigationDrawerSample()
                        CardSample()
                        ElevatedCardSample()
                        OutlinedCardSample()
                        SurfaceSample()
                        ClickableSurfaceSample()
                        SelectableSurfaceSample()
                        ToggleableSurfaceSample()
                        SquareButtonSample()
                        TextButtonSample()
                    }
                }
            }
        }
    }

    companion object{
    }
}